home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
n_b_v203.zip
/
TINPUT.TXT
< prev
next >
Wrap
Text File
|
1996-07-04
|
26KB
|
507 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME TINPUT .TXT ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
$endif
┌──────────────────────────────────────────────────────────────────┐
│ fTinput$ and fTinputM$ both use the same TINPUT_?.INC files. │
└──────────────────────────────────────────────────────────────────┘
Before you get into all of this: The info in this file is vital but,
despite the length of the file it is NOT difficult to understand if
you don't try to make it into something more than it is. The concept
was taught to me by my guru in about 30 seconds on the margin of the
daily news paper! So, if I can grasp it that fast, nuff said! d;D
A program is not worth much if it cannot input data and instructions
from the user; how this information and data is input is one of the
most important features of any program. It should be as easy and as
fool-proof as possible. Your job, as programmer, is to make all this
happen.
As there are several different types of data one all-purpose routine
just doesn't make the cut! On the other hand, to attempt to have an
individual routine for each style is just too much to handle. I have
come up with a happy medium: a suite of routines that allows you to
call a single function from within your program. It calls a specific
handler for the data style required. Sorta' like one stop shopping!
There are 9 field styles. Eight of them provide specific support and
the ninth is a general, all-purpose field that catches everything
else. The fields are controlled by a string of data that you send.
The string is loaded into a TYPE by the function before it is passed
to the specific handler.
As you can see the first 8 bytes of the control string fit into the
TYPE but from position nine and on you can also send more data for
some of the styles that require it or can use it. This area of the
string is known an the MASK. Also, not all the members of the TYPE
are used by all the styles and .Misc is a kind of catch-all member.
Despite their comings and goings, the members hold their purpose in
life throughout. Below is a generalized description for each member
then a style by style discussion.
┌──────────────────────────────────────────────────────────────────┐
│ One important thing to remember is that fTinput assumes that the │
│ incoming data is IN THE CORRECT FORMAT for the designated Style. │
└──────────────────────────────────────────────────────────────────┘
TYPE TinputTYPE '┌───────────────────────────────────
Style AS STRING * 1 '│ field type ie: A,B,D,H,M,N,P,Q,T
Row AS BYTE '│ screen row
Col AS BYTE '│ left most screen column
Cols AS BYTE '│ N° of visible columns
MustBe AS BYTE '│ > 0 if field is mandatory
Cased AS BYTE '│ 0 = none 1 = UCASEed 2 = LCASEed
Misc AS BYTE '│ max length of string => Cols
Just AS BYTE '│ N° of routine to call fJUSTIFY$ with
END TYPE '└────────────────────────┤ 9 bytes ├───
.Style always indicates which field driver to use
.Row always the starting screen row for the field
.Col always the left-most column(s) for the field
.Cols always the maximum visible columns of the field
in most cases this is also the maximum length of the field
.MustBe if > 0 then the field is mandatory
this field is used differently by each style
.Cased if 0 then no casing is done to the input
if 1 then all input is UCASEd using UCASEstr
if 2 then all input is LCASEd using LCASEstr
.Misc used differently by each style
.Just an extra byte for your use as it is NOT used by fTinput$
──────────────────────────────────────────────────────────────────────────
ANYTHING GOES
──────────────────────────────────────────────────────────────────────────
Style = "A" Anything goes
Row = 1 -> x screen row
Col = 1 -> x left most screen column
Cols = 1 -> x N° of visible columns
MustBe = 0 or x > 0 if field is mandatory
Cased = 0, 1 or 2 0 = NOCASING 1 = UCASEed 2 = LCASEed
Misc = x maximum field length if => Cols
Just = x NOT USED
Mask$ = if NULL any characters accepted
ELSE only chars in Mask$ eg: " 0123456789-"
DATA IN : any string value from NULL to .Misc in length
DATA OUT: a string of up to .Col or .Misc length
As you can see this field can and will scroll through a long string of
data. By using Mask$ you can restrict the keyboard input to only a few
keys. ie: "0123456789-() " works well for phone numbers
Another property of Alpha is that it will automatically issue a CHR$(13)
if .Cols = 1 and an acceptable key is input. This allows you to use ALPHA
for yes/no answers and the like, but QUERY does a better job of it.
──────────────────────────────────────────────────────────────────────────
BLOCK O' TEXT
──────────────────────────────────────────────────────────────────────────
Style = "B" Block of text
Row = 1 -> x top most screen row
Col = 1 -> x left most screen column
Cols = 1 -> x N° of columns
MustBe = NOT USED 0 is assumed
Cased = NOT USED 0 is assumed
Misc = x maximum number of rows of .Cols chars
Just = NOT USED
Mask$ = NOT USED
DATA IN : any string of text
DATA OUT: a string of text
A simple word-wrap is employed SEE: fWrapPosF%
<UP> and <DOWN> keys are used and <ENTER> acts as <DOWN>
fTinput$ can return <UP> and <DOWN> as defaults from this function
──────────────────────────────────────────────────────────────────────────
DATES
──────────────────────────────────────────────────────────────────────────
Style = "D" Dates
Row = 1 -> x screen row
Col = 1 -> x left most screen column
Cols = 8 or 10 8 is default ( + LEN(day$) )
MustBe = 0 or x > 0 if field is mandatory
Cased = NOT USED
Misc = NOT USED
Just = NOT USED
Mask$ = "Sun |Mon |Tue |Wed |Thr |Fri |Sat "
NOTE: if Mask$ is used
* all day names need be the same length
* .Cols must include this length
* D$ is _NOT_ effected
The data field looks like "Mon 01-01-1995"
and the user only inputs the date not the
day.
DATA IN : an 8 or 10 character date string in SetDateFormat style
DATA OUT: same as data in
If .MustBe > 0 and incoming D$ is NULL then the system's date is used
ELSE
Before the field exits the date entered must be a correct and legal date
or a NULL field will exit with a value of SPACE$(.Cols) and display.
The grey "*" resets the date to the current date
"-" - 1 day (yesterday) ' these keys come in handy, along
<CTRL>"-" - 28 days (